package com.vidaappv1;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class OrderAdapter extends ArrayAdapter<OrderItems>{
	
	private ArrayList<OrderItems> orderlist;
	private Context context;
	
	public OrderAdapter(ArrayList<OrderItems> orderlist,Context ctx){
		super(ctx,R.layout.row_layout,orderlist);
		this.orderlist = orderlist;
		this.context = ctx;
	}
	
	public View getView(int position,View convertView,ViewGroup parent){
		if(convertView ==null){
			//This is a new View we inflate the new layout
			LayoutInflater inflater = 	(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = inflater.inflate(R.layout.row_layout,parent,false);
		}
			//Now we can fill the layout with the right values
			TextView tvDrink =(TextView)convertView.findViewById(R.id.drink);
			TextView tvPrice =(TextView)convertView.findViewById(R.id.price);
			OrderItems item = orderlist.get(position);
			
			tvDrink.setText(item.getName());
			tvPrice.setText("R" + item.getPrice());
		return convertView;
	}

}
